<template>
	<view class="goods-page">
		<u-navbar :autoBack="true" title="店铺管理" :placeholder="true" bgColor="rgba(255,255,255,0)"></u-navbar>
		<view class="top-box">
			<view class="info-box">
				<view class="image" v-if="info.avatar">
					<image :src="'https://m.lqvvvv.com'+info.avatar" mode=""></image>
				</view>
				<view class="info">
					<view class="info-name">{{info.title}}</view>
					<view class="info-mintitle">{{info.address}}</view>
					<view class="tags">
						<view class="item" v-for="(item,index) in info.tags" :key="index">{{item}}</view>
					</view>
				</view>
			</view>
			<view class="btn-box">
				<view :class="type == 0?'btnselse':'btn'" @click="goselse(0)">歇业</view>
				<view :class="type == 1?'btnselse':'btn'" @click="goselse(1)">营业</view>
			</view>
		</view>
		<view class="info-list">
			<view class="list-item" @click="$navTo.togo('/pages/business/edit/index')">
				<view class="text">
					<view class="title">编辑店铺</view>
					<view class="mintitle">填写店铺信息</view>
				</view>
				<view>
					<image src="https://m.lqvvvv.com/assets/static/business/bu-icon1.png" mode=""></image>
				</view>
			</view>
			<view class="list-item"  @click="$navTo.togo('/pages/business/upgoods/index')">
				<view class="text">
					<view class="title">发布商品</view>
					<view class="mintitle">发布上架商品</view>
				</view>
				<view>
					<image src="https://m.lqvvvv.com/assets/static/business/bu-icon2.png" mode=""></image>
				</view>
			</view>
			<view class="list-item" @click="$navTo.togo('/pages/business/goodslist/index',{id:info.id})">
				<view class="text">
					<view class="title">商品管理</view>
					<view class="mintitle">店铺商品上架</view>
				</view>
				<view>
					<image src="https://m.lqvvvv.com/assets/static/business/bu-icon3.png" mode=""></image>
				</view>
			</view>
			<view class="list-item" @click="$navTo.togo('/pages/business/business-list/index')"> 
				<view class="text">
					<view class="title">订单列表</view>
					<view class="mintitle">商家订单信息</view>
				</view>
				<view>
					<image src="https://m.lqvvvv.com/assets/static/business/bu-icon4.png" mode=""></image>
				</view>
			</view>
			<!-- <view class="list-item" @click="$navTo.togo('/pages/business/release/index')">
				<view class="text">
					<view class="title">发起活动</view>
					<view class="mintitle">发布组局套餐</view>
				</view>
				<view>
					<image src="https://m.lqvvvv.com/images/bu-icon5.png" mode=""></image>
				</view>
			</view> -->
		</view>
		<view class="qr-c" @click="gosm">
			<view class="qr-c-item">
				<view class="text">
					<view class="title">扫码核销</view>
					<view class="mintitle">扫码核销信息</view>
				</view>
				<view>
					<image src="https://m.lqvvvv.com/assets/static/business/bu-icon5.png" mode=""></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: 'rgba(0,0,0,0.0)',
				},
				type: 1,
				info: {},
			}
		},
		onLoad() {
			this.getinfo()
		},
		methods: {
			gosm() {
				let app = this
				uni.scanCode({
					success: function(res) {
						console.log('条码内容：' + res.result);
						app.clend(res.result)
					}
				});
			},
			getinfo() {
				let params = {

				}
				this.$Request({
					method: 'POST',
					url: '/api/user_shop/getApproveStatus',
					data: params,
					ismsg: false,
				}).then(res => {
					if (res.code == 1) {
						this.info = res.data
						this.info.tags = this.info.tags.split(",")
						this.type = this.info.status
					}
				})
			},
			clend(id) {
				uni.showLoading({
					mask: true,
				})
				let params = {
					orderid:id
				}
				this.$Request({
					method: 'POST',
					url: '/api/shop_order/writeOff',
					data: params,
					ismsg: true,
				}).then(res => {
					uni.hideLoading()
				})
			},
			gonavto(url) {
				uni.navigateTo({
					url: url
				})
			},
			goselse(i) {
				uni.showLoading({
					title: "加载中...",
					mask: true
				})
				let params = {
					status: i
				}
				this.$Request({
					method: 'POST',
					url: '/api/user_shop/setStatus',
					data: params,
					ismsg: true,
				}).then(res => {
					if (res.code == 1) {
						uni.hideLoading()
						this.type = i
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.goods-page {
		min-height: 100vh;
		background-image: url('https://m.lqvvvv.com/assets/static/index/nav-bg.png');
		background-repeat: no-repeat;
		background-size: 100% 800rpx;
		padding: 30rpx;
		background-color: #F7F8FC;
		.qr-c{
			background: linear-gradient( 93deg, #FFC4FE 0%, #C3CCFF 100%);
			border-radius: 20rpx;
			padding: 20rpx;
			margin-top: 10rpx;
			.qr-c-item{
				display: flex;
				align-items: center;
				justify-content: space-between;
				image{
					width: 98rpx;
					height: 98rpx;
				}
				.text {
					.title{
						font-weight: bold;
						font-size: 28rpx;
						color: #000000;
					}
					.mintitle{
						font-weight: 500;
						font-size: 24rpx;
						color: #000000;
						margin-top: 10rpx;
					}
				}
			}
		}
		.info-list {
			width: 100%;
			margin-top: 50rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			flex-wrap: wrap;
			.list-item {
				width: 48%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 20rpx;
				border-radius: 20rpx;
				margin-bottom: 20rpx;
				background-color: #ffffff;
				image{
					width: 98rpx;
					height: 98rpx;
				}
				.text {
					.title{
						font-weight: bold;
						font-size: 28rpx;
						color: #000000;
					}
					.mintitle{
						font-weight: 500;
						font-size: 24rpx;
						color: #000000;
						margin-top: 10rpx;
					}
				}
			}
		}

		.top-box {
			width: 100%;
			margin-top: 20rpx;
			background-color: #ffffff;
			padding: 20rpx;
			border-radius: 20rpx;

			.btn-box {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 30rpx;

				.btn {
					width: 46%;
					background: #DBDBDB;
					border-radius: 20rpx;
					text-align: center;
					padding: 20rpx 0;
					font-weight: bold;
					font-size: 28rpx;
					color: #000000;
				}

				.btnselse {
					width: 46%;
					background: #5755F2;
					border-radius: 20rpx;
					text-align: center;
					padding: 20rpx 0;
					font-weight: bold;
					font-size: 28rpx;
					color: #ffffff;
				}
			}

			.info-box {
				display: flex;

				.image {
					image {
						width: 132rpx;
						height: 132rpx;
						border-radius: 10rpx;
					}
				}

				.info {
					margin-left: 20rpx;

					.info-name {
						font-weight: bold;
						font-size: 28rpx;
						color: #333333;
					}

					.info-mintitle {
						font-weight: 400;
						font-size: 24rpx;
						color: #173F93;
						margin-top: 10rpx;
					}

					.tags {
						display: flex;
						align-items: center;
						margin-top: 12rpx;

						.item {
							padding: 6rpx 15rpx;
							margin-right: 10rpx;
							background: #F0F0F0;
							border-radius: 18rpx 18rpx 18rpx 0rpx;
							font-weight: 400;
							font-size: 20rpx;
							color: #333333;
						}
					}
				}
			}
		}
	}
</style>